package db;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import config.SystemConfig;

import user.view.LoginView;
import user.view.UserMain;


public class CitiesManager {
	public static ArrayList<String[]> getCities()
	{
		
		String sql="select * from cities;";
		ArrayList<String[]> cities=new ArrayList<String[]>();
		if(SystemConfig.offline)
		{
			
			String[] citiesStrings={"Landon","Tokyo","BeiJing","NewYork","Sydney","Canberra","ShangHai","HongKong","Macao","TaiBei","TianJin"};
			for(int i=0;i<11;i++)
			{
				String[] t=new String[3];
				t[0]=citiesStrings[i];
				t[1]=50+"";
				t[2]=(i+1)+"";
				cities.add(t);
			}
			return cities;
		}
		
		try {
			ResultSet rs=DataBaseManager.getConnection().createStatement().executeQuery(sql);
			while(rs.next())
			{
				String[] strings=new String[3];
				strings[0]=rs.getString("city");
				strings[1]=rs.getString("tax");
				strings[2]=rs.getString("id");
				cities.add(strings);
			}
			return cities;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			
		}
		return cities;
	}
}
